//
//  CGFloat+To.swift
//  TTCOM
//
//  Created by Toj on 7/19/23.
//

import Foundation

// MARK: - To Font
public extension CGFloat {
    
    // MARK: - System font
    var to_systemFont: UIFont {
        return UIFont.systemFont(ofSize: self)
    }
    
    var to_boldFont: UIFont {
        return UIFont.boldSystemFont(ofSize: self)
    }
    
    // MARK: - Roboto font
    var to_rbtLightFont: UIFont {
        return to_lightFont(name: .roboto) ?? to_systemFont
    }
    
    var to_rbtRegularFont: UIFont {
        return to_regularFont(name: .roboto) ?? to_systemFont
    }
    
    var to_rbtMediumFont: UIFont {
        return to_mediumFont(name: .roboto) ?? to_systemFont
    }
    
    var to_rbtBoldFont: UIFont {
        return to_boldFont(name: .roboto) ?? to_boldFont
    }
    
    // MARK: - Custom font
    /// 细体: 300
    func to_lightFont(name: UIFont.TTName) -> UIFont? {
        return UIFont(name: name, weight: .light, size: self)
    }
    
    /// 标准: 400
    func to_regularFont(name: UIFont.TTName) -> UIFont? {
        return UIFont(name: name, weight: .regular, size: self)
    }
    
    /// 适中: 500
    func to_mediumFont(name: UIFont.TTName) -> UIFont? {
        return UIFont(name: name, weight: .medium, size: self)
    }
    
    /// 粗体: 700
    func to_boldFont(name: UIFont.TTName) -> UIFont? {
        return UIFont(name: name, weight: .bold, size: self)
    }
}

public extension CGFloat {
    
    /// 角度转pi
    var to_pi: CGFloat {
        return self / 180 * CGFloat.pi
    }
}
